import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { Language } from "../../../../../extend/language/Language";
import { GTextArea } from "../../../../../com/mui/controls/GTextArea";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { SkillInfo } from "../../../model/SkillInfo";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { CareerUtil } from "../../common/util/CareerUtil";
import { Cache } from "../../../cache/Cache";
//class SkillBookPanel
    
    export  class SkillBookPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._useDes = new Object /* flash.text.TextField */();
            this.initUI();
            mouseEnabled = false;
            mouseChildren = false;
            return;
        }

        /* internal  */initUI(): void
        {
            this._titleTxt = new Object /* flash.text.TextField */();
            this._titleTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._titleTxt.filters = [FilterConst.nameGlowFilter];
            this._titleTxt.height = 30;
            this._titleTxt.width = 120;
            this._titleTxt.defaultTextFormat = new GTextFormat("", 14, 16774954);
            this._titleTxt.x = 0;
            this._titleTxt.y = 0;
            this._titleTxt.textColor = 16774954;
            this._titleTxt.text = Language.getString(20670);
            addChild(this._titleTxt);
            this._bookTxt = new GTextArea();
            this._bookTxt.styleName = "GTextArea";
            this._bookTxt.wordWrap = true;
            this._bookTxt.textField.defaultTextFormat = new GTextFormat(FontUtil.songtiName, 12, 16107367, null, null, null, null, null, flash.text.TextFormatAlign.LEFT, null, null, null, 4);
            this._bookTxt.textField.selectable = false;
            this._bookTxt.editable = false;
            this._bookTxt.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._bookTxt.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._bookTxt.width = 210;
            this._bookTxt.height = 140;
            this._bookTxt.x = 0;
            this._bookTxt.y = 25;
            addChild(this._bookTxt);
            this._preInfo = new Object /* flash.text.TextField */();
            this._preInfo.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._preInfo.filters = [FilterConst.nameGlowFilter];
            this._preInfo.height = 30;
            this._preInfo.width = 210;
            this._preInfo.x = this._titleTxt.x;
            this._preInfo.y = this._bookTxt.y + this._bookTxt.height + 20;
            this._preInfo.defaultTextFormat = new GTextFormat("", 14, 16774954);
            addChild(this._preInfo);
            this._useDesLabel = new GLabel();
            this._useDesLabel.x = 0;
            this._useDesLabel.y = 111;
            this._useDesLabel.htmlText = HTMLUtil.addColor(Language.getString(20692).substr(0, 2) + "：", "#F5C767");
            addChild(this._useDesLabel);
            this._useDes.wordWrap = true;
            this._useDes.multiline = true;
            this._useDes.selectable = false;
            this._useDes.height = 140;
            this._useDes.width = 172;
            this._useDes.textColor = 16580298;
            this._useDes.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._useDes.x = 37;
            this._useDes.y = 108;
            addChild(this._useDes);
            return;
        }

        public updateData(arg1: SkillInfo): void
        {
            var loc1=0;
            var loc3=null;
            this.dispose();
            this._skillInfo = arg1;
            var loc2=arg1.getBookInfos.length;
            while (loc1 < loc2) 
            {
                loc3 = arg1.getBookInfos[loc1];
                if (loc1 != (loc2 - 1)) 
                {
                    loc3 = loc3 + "\n\n";
                }
                this._bookTxt.htmlText = this._bookTxt.htmlText + HTMLUtil.addColor(loc3, GlobalStyle.color1);
                ++loc1;
            }
            var loc4=this._skillInfo.preSkill;
            var loc5=this._skillInfo.preLearned ? "#00ff00" : "#ff0000";
            var loc6=this._skillInfo.preLearned ? Language.getString(20671) : Language.getString(20672);
            if (loc4 != null) 
            {
                this._preInfo.htmlText = HTMLUtil.addColor(Language.getString(20673) + "：", "#fff72a") + HTMLUtil.addColor(loc4.skillName + loc6, loc5);
            }
            else 
            {
                this._preInfo.text = "";
            }
            this._useDes.htmlText = HTMLUtil.addColor(this._skillInfo.tSkill.skillDescription, "#b1efff");
            var loc7;
            if ((loc7 = this._useDes.textHeight) > 75 && !CareerUtil.isGradeCareer(Cache.instance.role.careerEnabled)) 
            {
                this._useDesLabel.y = 107 - (loc7 - 75);
            }
            else 
            {
                this._useDesLabel.y = 107;
            }
            this._useDes.y = this._useDesLabel.y - 2;
            return;
        }

        public dispose(): void
        {
            this._skillInfo = null;
            this._bookTxt.text = "";
            this._preInfo.text = "";
            return;
        }

        /* internal */ /* var */_titleTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_bookTxt: GTextArea;

        /* internal */ /* var */_preInfo: Object /* flash.text.TextField */;

        /* internal */ /* var */_useDesLabel: GLabel;

        /* internal */ /* var */_useDes: Object /* flash.text.TextField */;

        /* internal */ /* var */_skillInfo: SkillInfo;
    }
